package com.lmx.repoDomain.tmodel;

import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiLookupIncludeAutomatically;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;

@JsonApiResource(type = "customerserviceitem")
@Table(name = "tnb_customer_serviceitem")
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class CustomerServiceItem extends BaseEntity {

	private String price;//

	private String remark;// 备注

	private String name;

	private User lastUpdateUser;// 更新操作者userid

	private Integer createDateTime;// 创建时间

	private User createUser;

	private Integer lastUpdateDateTime;// 更新时间

	private String serviceTime;// 服务时长

	private String frequency;// 频次

	private Dicttype period;// 周期

	private Dicttype careType;// 护理类型

	private Dicttype countType;// 统计类型

	private Dicttype roleType;// 角色类型

	private Dicttype serviceType;// 类型

	private Integer referencePrice;// 参考价格

	private List<ServiceFinishLevel> finishLevels;

	private List<ServiceMerch> merchs;

	private String serviceNum;

	private Dicttype serviceValueType;//

	private Set<RiskLevel> levels;

	private String code;

	private Dicttype serviceSource;// 机构服务jigou 居家服务jujia

	private String picture;

	@Column(name = "picture")
	public String getPicture() {
		return picture;
	}

	public void setPicture(String picture) {
		this.picture = picture;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "service_source_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getServiceSource() {
		return serviceSource;
	}

	public void setServiceSource(Dicttype serviceSource) {
		this.serviceSource = serviceSource;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "service_value_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getServiceValueType() {
		return serviceValueType;
	}

	public void setServiceValueType(Dicttype serviceValueType) {
		this.serviceValueType = serviceValueType;
	}

	@Column(name = "service_num")
	public String getServiceNum() {
		return serviceNum;
	}

	public void setServiceNum(String serviceNum) {
		this.serviceNum = serviceNum;
	}

	@JsonApiToMany
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "item")
	public List<ServiceMerch> getMerchs() {
		return merchs;
	}

	public void setMerchs(List<ServiceMerch> merchs) {
		this.merchs = merchs;
	}

	@JsonApiToMany
	@JsonApiLookupIncludeAutomatically
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "item")
	public List<ServiceFinishLevel> getFinishLevels() {
		return finishLevels;
	}

	public void setFinishLevels(List<ServiceFinishLevel> finishLevels) {
		this.finishLevels = finishLevels;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "servicetype_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getServiceType() {
		return serviceType;
	}

	public void setServiceType(Dicttype serviceType) {
		this.serviceType = serviceType;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "roletype_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getRoleType() {
		return roleType;
	}

	public void setRoleType(Dicttype roleType) {
		this.roleType = roleType;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "counttype_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getCountType() {
		return countType;
	}

	public void setCountType(Dicttype countType) {
		this.countType = countType;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "period_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getPeriod() {
		return period;
	}

	public void setPeriod(Dicttype period) {
		this.period = period;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "careType_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getCareType() {
		return careType;
	}

	public void setCareType(Dicttype careType) {
		this.careType = careType;
	}

	@Column(name = "service_time")
	public String getServiceTime() {
		return serviceTime;
	}

	public void setServiceTime(String serviceTime) {
		this.serviceTime = serviceTime;
	}

	@Column(name = "frequency")
	public String getFrequency() {
		return frequency;
	}

	public void setFrequency(String frequency) {
		this.frequency = frequency;
	}

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public CustomerServiceItem() {
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "price")
	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	@Column(name = "reference_price")
	public Integer getReferencePrice() {
		return referencePrice;
	}

	public void setReferencePrice(Integer referencePrice) {
		this.referencePrice = referencePrice;
	}

	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH, mappedBy = "serviceItem")
	@Fetch(FetchMode.SELECT)
	@JsonApiToMany
	@JsonApiLookupIncludeAutomatically
	public Set<RiskLevel> getLevels() {
		return levels;
	}

	public void setLevels(Set<RiskLevel> levels) {
		this.levels = levels;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

}
